home *** CD-ROM | disk | FTP | other *** search
/ Computer Select (Limited Edition) / Computer Select.iso / dobbs / v17n03 / oopasm.exe / VERTMENU.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-07-22  |  2.2 KB  |  104 lines

  1.     .MODEL    SMALL
  2.  
  3.     INCLUDE    equates.inc
  4.     INCLUDE    instance.inc
  5.     INCLUDE    messages.inc
  6.     INCLUDE    objects.inc
  7.  
  8. IF1
  9.     INCLUDE    macros.mac
  10.     INCLUDE    objects.mac
  11. ENDIF
  12.  
  13.     EXTRN    prtString:NEAR
  14.     EXTRN    sendMsg:NEAR
  15.  
  16.     EXTRN    DBorder:WORD
  17.     EXTRN    Dispatch:WORD
  18.     EXTRN    Menu:WORD
  19.     EXTRN    Mouse:WORD
  20.     EXTRN    PopUp:WORD
  21.     EXTRN    Self:WORD
  22.     EXTRN    System:WORD
  23.  
  24.     .CODE
  25.  
  26.     PUBLIC    disVertMenu
  27. COMMENT    %
  28. ==============================================================================
  29. Displays a vertical menu.
  30.  
  31. =============================================================================%
  32. disVertMenu    PROC    NEAR
  33.     getInst        dh,Row1,Self        ;Get upper row
  34.     getInst        dl,Col1            ;Get left column
  35.     getInst        ch,Row2            ;Get lower row
  36.     getInst        bl,Color        ;Get color
  37.     getInst        di,MenuPtr        ;Menu pointer
  38.  
  39.     dec        ch            ;Decrement lower row
  40.     inc        dl            ;Account for left border
  41.  
  42. dvm1:    inc        dh            ;Increment row
  43.     mov        Wptr[di],dx        ;Save row/column
  44.     mov        si,Wptr[di+2]        ;Pass ptr to text string
  45.     call        prtString        ;Display menu item
  46.     add        di,4            ;Point to next menu entry
  47.     neq        dh,ch,dvm1        ;Not at bottom? - Loop
  48.  
  49.     ret
  50. disVertMenu    ENDP
  51.  
  52.  
  53.  
  54. IF Dbug
  55.     PUBLIC    hiliteMenuItem
  56. ENDIF
  57. COMMENT    %
  58. ==============================================================================
  59. Hilites the menu item based on mouse location.
  60.  
  61. =============================================================================%
  62. hiliteMenuItem    PROC    NEAR
  63.     getInst        bl,Row1,Mouse        ;Get mouse row
  64.     getInst        si,MenuPtr,Self        ;Get menu ptr
  65.     xor        ax,ax            ;Initialize item counter
  66.  
  67. hmi1:    mov        dl,Bptr[si+1]        ;Get row for current item
  68.     mov        dh,Bptr[si+MenuEntrySize+1]    ;Get row for next item
  69.     lessThan    bl,dl,hmi4        ;Exit if before item
  70.     lessThan    bl,dh,hmi3        ;Done if before next item
  71.     inc        ax            ;Increment item count
  72.     add        si,MenuEntrySize    ;Point to next entry
  73.     identity    Wptr[si],hmi1,hmi4    ;Loop if more items
  74.                         ;Else exit
  75.  
  76. hmi3:    mov        cl,MenuEntrySize    ;Get entry size
  77.     mul        cl            ;Calc entry offset
  78.     send        Self,Hilite,ax        ;Hilite menu item
  79.  
  80. hmi4:    ret
  81. hiliteMenuItem    ENDP
  82.  
  83.  
  84.  
  85.     .DATA
  86.  
  87. defMsg    VertMenu,\
  88.     Refresh,\
  89.     <,,disVertMenu>
  90.  
  91. defMsg    VertMenu,\
  92.     Drag,\
  93.     <,,hiliteMenuItem>
  94.  
  95. defObj    VertMenu,\
  96.     <PopUp,DBorder,Menu,Dispatch>,\
  97.     <>,\
  98.     <Refresh,Drag>
  99.  
  100.  
  101.  
  102.  
  103.     END
  104.